(* Content-type: application/mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 6.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       145,          7]
NotebookDataLength[     16437,        398]
NotebookOptionsPosition[     15167,        352]
NotebookOutlinePosition[     15763,        376]
CellTagsIndexPosition[     15678,        371]
WindowFrame->Normal
ContainsDynamic->False*)

(* Beginning of Notebook Content *)
Notebook[{

Cell[CellGroupData[{
Cell["Testing the CppFunctions directly", "Subsubtitle",
 CellChangeTimes->{{3.402946860609285*^9, 3.4029468724663343`*^9}, {
  3.4029469046325874`*^9, 3.4029469392924256`*^9}, {3.402947110688882*^9, 
  3.402947116246874*^9}, {3.402947157846691*^9, 3.4029471854263487`*^9}, {
  3.408119018206829*^9, 3.408119040248523*^9}, {3.408199323227232*^9, 
  3.4081993321901197`*^9}, {3.4081994238318944`*^9, 3.408199471039776*^9}, {
  3.408199726957768*^9, 3.40819974928988*^9}, {3.4082060613461714`*^9, 
  3.4082060626780863`*^9}, {3.408206333427405*^9, 3.4082063466363983`*^9}}],

Cell[BoxData[{
 RowBox[{
  RowBox[{"setconstants", ":=", 
   RowBox[{"(", 
    RowBox[{
     RowBox[{"Global`DAQDefault", "=", "0"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`RSE", "=", "1"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`NonRSE", "=", "2"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`Differential", "=", "3"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`Rising", "=", "0"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`Falling", "=", "1"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`Volts", "=", "0"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`CustomScale", "=", "1"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`Finite", "=", "0"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`Continuous", "=", "1"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`WaitForever", "=", 
      RowBox[{"-", "1"}]}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`Omit", "=", "0"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`Include", "=", "1"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`Interrupts", "=", "0"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Global`DMA", "=", "1"}], ";"}], 
    RowBox[{"(*", 
     RowBox[{"DMA", "=", 
      RowBox[{"direct", " ", "memory", " ", "access"}]}], "*)"}], ")"}]}], 
  ";"}], "\[IndentingNewLine]", "setconstants", "\n", 
 RowBox[{"listforcall", "=", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"\"\<channels\>\"", ",", "\"\<dev1/ai0\>\""}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<numchannels\>\"", ",", "1"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<frequency\>\"", ",", 
      RowBox[{"N", "[", "100.0", "]"}]}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<samples\>\"", ",", "50"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<terminalmode\>\"", ",", "Differential"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<min\>\"", ",", 
      RowBox[{"N", "[", 
       RowBox[{"-", "10.0"}], "]"}]}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<max\>\"", ",", 
      RowBox[{"N", "[", "10.0", "]"}]}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<units\>\"", ",", "Volts"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<clock\>\"", ",", "\"\<OnboardClock\>\""}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<activeedge\>\"", ",", "Rising"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<samplemode\>\"", ",", "Finite"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<timeout\>\"", ",", 
      RowBox[{"N", "[", "10", "]"}]}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<messagelevel\>\"", ",", "0"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<setuponly\>\"", ",", "0"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"\"\<transfermech\>\"", ",", "DMA"}], "}"}]}], 
   "}"}]}], "\[IndentingNewLine]"}], "Input",
 CellChangeTimes->{{3.402946860609285*^9, 3.4029468724663343`*^9}, {
   3.4029469046325874`*^9, 3.4029469392924256`*^9}, {3.402947110688882*^9, 
   3.402947116246874*^9}, {3.402947157846691*^9, 3.4029471854263487`*^9}, {
   3.408119018206829*^9, 3.408119040248523*^9}, {3.408199323227232*^9, 
   3.4081993321901197`*^9}, {3.4081994238318944`*^9, 3.408199447826397*^9}, 
   3.4081994807837873`*^9, {3.408206390168995*^9, 3.40820639024911*^9}, {
   3.4082071174948387`*^9, 3.408207117815299*^9}}],

Cell[BoxData[{
 RowBox[{"debugLink", "=", " ", 
  RowBox[{"Install", "[", 
   RowBox[{"\"\<getvolt\>\"", ",", 
    RowBox[{"LinkMode", "\[Rule]", "Connect"}]}], "]"}]}], "\n", 
 RowBox[{"GetVoltagesCpp", "[", "listforcall", "]"}], "\n", 
 RowBox[{"Uninstall", "[", "debugLink", "]"}]}], "Input",
 CellChangeTimes->{{3.402946860609285*^9, 3.4029468724663343`*^9}, {
   3.4029469046325874`*^9, 3.4029469392924256`*^9}, {3.402947110688882*^9, 
   3.402947116246874*^9}, {3.402947157846691*^9, 3.4029471854263487`*^9}, {
   3.408119018206829*^9, 3.408119040248523*^9}, {3.408199323227232*^9, 
   3.4081993321901197`*^9}, {3.4081994238318944`*^9, 3.408199447826397*^9}, {
   3.4081994807837873`*^9, 3.4081995032761297`*^9}, 3.408199693008952*^9}],

Cell[BoxData[{
 RowBox[{
  StyleBox["link",
   FontColor->GrayLevel[0]], 
  StyleBox["=",
   FontColor->GrayLevel[0]], 
  RowBox[{
   StyleBox["Install",
    FontColor->GrayLevel[0]], 
   StyleBox["[",
    FontColor->GrayLevel[0]], 
   "\"\<C:\\\\math\\\\mathDAQ\\\\build_MinGW421\\\\debug\\getvoltagestm.exe\>\
\"", "]"}]}], "\n", 
 RowBox[{"GetVoltagesCpp", "[", "listforcall", "]"}], "\[IndentingNewLine]", 
 RowBox[{"Uninstall", "[", "link", "]"}]}], "Input",
 CellChangeTimes->{
  3.408199685017461*^9, {3.408199911543189*^9, 3.4081999490871744`*^9}, {
   3.4081999844179773`*^9, 3.4082000324370255`*^9}, {3.40820011106008*^9, 
   3.408200123297677*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"getfiles", "[", "versionDir_", "]"}], ":=", 
  RowBox[{"(", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"SetDirectory", "[", 
     RowBox[{"StringJoin", "[", 
      RowBox[{
      "basedir", ",", "\"\<\\\\\>\"", ",", " ", "versionDir", ",", " ", 
       "\"\<\\\\\>\"", ",", "\"\<debug\>\""}], "  ", "]"}], "]"}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{"Print", "[", 
     RowBox[{"Directory", "[", "]"}], "]"}], ";", "\[IndentingNewLine]", 
    RowBox[{"Print", "[", 
     RowBox[{"FileNames", "[", "]"}], "]"}], ";", "\[IndentingNewLine]", 
    RowBox[{
     StyleBox["link",
      FontColor->GrayLevel[0]], 
     StyleBox["=",
      FontColor->GrayLevel[0]], 
     RowBox[{
      StyleBox["Install",
       FontColor->GrayLevel[0]], 
      StyleBox["[",
       FontColor->GrayLevel[0]], "\"\<getvoltagestm.exe\>\"", "]"}]}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{"data", " ", "=", 
     RowBox[{"GetVoltagesCpp", "[", "listforcall", "]"}]}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{"Uninstall", "[", "link", "]"}], ";", "\[IndentingNewLine]", 
    RowBox[{"ResetDirectory", "[", "]"}], ";", "\[IndentingNewLine]", 
    "data"}], ")"}]}]], "Input",
 CellChangeTimes->{{3.4082006685817566`*^9, 3.4082007840878468`*^9}, {
   3.4082008884879665`*^9, 3.408200958829112*^9}, {3.4082010470960336`*^9, 
   3.408201047226221*^9}, {3.4082011055601006`*^9, 3.4082011923448915`*^9}, {
   3.408202350600381*^9, 3.408202361816509*^9}, {3.4082024709634542`*^9, 
   3.4082025010767555`*^9}, {3.4082025868300624`*^9, 
   3.4082026011406403`*^9}, {3.408202642119565*^9, 3.4082026529851885`*^9}, {
   3.408202799606019*^9, 3.408202917425435*^9}, {3.408202969219912*^9, 
   3.4082031803835506`*^9}, {3.408203240089403*^9, 3.408203356626976*^9}, {
   3.4082035139231567`*^9, 3.408203579647664*^9}, {3.408203616610814*^9, 
   3.408203653303576*^9}, {3.408203730945219*^9, 3.408203838940509*^9}, {
   3.408203874191197*^9, 3.408203964521085*^9}, {3.4082039983096704`*^9, 
   3.4082040809985714`*^9}, {3.4082041219975247`*^9, 3.408204162956421*^9}, {
   3.4082042309441824`*^9, 3.408204231064355*^9}, {3.408204322636029*^9, 
   3.408204323146763*^9}, {3.408204360700763*^9, 3.4082044073478384`*^9}, {
   3.408204572074704*^9, 3.408204632301306*^9}, {3.4082048204318237`*^9, 
   3.40820482618009*^9}, {3.4082049223884306`*^9, 3.4082049272954865`*^9}, {
   3.4082050455254927`*^9, 3.408205049090619*^9}, {3.4082051517682624`*^9, 
   3.4082052257246065`*^9}, {3.408205259643379*^9, 3.408205287954088*^9}, {
   3.408205362591411*^9, 3.4082054053729277`*^9}, 3.408205447954157*^9, {
   3.4082055162223215`*^9, 3.4082055168732576`*^9}, {3.408205933622514*^9, 
   3.4082059423049984`*^9}, {3.408206711020357*^9, 3.4082067162378592`*^9}, {
   3.4082067734000545`*^9, 3.408206802732232*^9}, 3.408206879242248*^9}],

Cell[BoxData[{
 RowBox[{
  RowBox[{"basedir", " ", "=", 
   RowBox[{"ToString", "[", 
    RowBox[{"SetDirectory", "[", 
     RowBox[{"StringJoin", "[", 
      RowBox[{
       RowBox[{"NotebookDirectory", "[", "]"}], ",", "\"\<..\\\\..\>\""}], 
      "]"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"versions", " ", "=", " ", 
   RowBox[{"FileNames", "[", "\"\<build*\>\"", "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{"Map", "[", 
  RowBox[{"getfiles", ",", "versions"}], "]"}]}], "Input",
 CellChangeTimes->{{3.4082041838765025`*^9, 3.408204192308627*^9}, {
  3.4082042333576527`*^9, 3.408204233467811*^9}, {3.408204325950795*^9, 
  3.408204328744813*^9}, {3.4082048848644733`*^9, 3.4082048858859425`*^9}, {
  3.4082051583777666`*^9, 3.408205158497939*^9}, {3.408205234377048*^9, 
  3.408205269878096*^9}, {3.408205314392104*^9, 3.408205330435173*^9}, {
  3.4082068316638336`*^9, 3.4082068334363823`*^9}, {3.408207211920616*^9, 
  3.4082072493544436`*^9}}],

Cell[BoxData[{
 RowBox[{"Links", "[", "]"}], "\[IndentingNewLine]", 
 RowBox[{"DirectoryStack", "[", "]"}]}], "Input",
 CellChangeTimes->{{3.4082062832152033`*^9, 3.4082062867202435`*^9}, {
  3.4082073208572593`*^9, 3.408207328408117*^9}}],

Cell[CellGroupData[{

Cell[BoxData[{
 RowBox[{"SetDirectory", "[", 
  "\"\<c:\\\\math\\\\mathDAQ\\\\build_VC8\\\\debug\>\"", 
  "]"}], "\[IndentingNewLine]", 
 RowBox[{
  StyleBox["link",
   FontColor->GrayLevel[0]], 
  StyleBox["=",
   FontColor->GrayLevel[0]], 
  RowBox[{
   StyleBox["Install",
    FontColor->GrayLevel[0]], 
   StyleBox["[",
    FontColor->GrayLevel[0]], "\"\<getvoltagestm.exe\>\"", 
   "]"}]}], "\[IndentingNewLine]", 
 RowBox[{"??", "SerialPortCommunicateCpp"}]}], "Input",
 CellChangeTimes->{{3.4088975446859837`*^9, 3.408897677456899*^9}, {
  3.408899578290163*^9, 3.4088995826764708`*^9}, {3.409431973015336*^9, 
  3.409431977752147*^9}, {3.409446974898755*^9, 3.409446977642701*^9}}],

Cell[BoxData["\<\"c:\\\\math\\\\mathDAQ\\\\build_VC8\\\\debug\"\>"], "Output",
 CellChangeTimes->{{3.409446956372115*^9, 3.4094469812979565`*^9}}],

Cell[BoxData[
 RowBox[{"LinkObject", "[", 
  RowBox[{"\<\"\\\".\\\\getvoltagestm.exe\\\"\"\>", ",", "8", ",", "7"}], 
  "]"}]], "Output",
 CellChangeTimes->{{3.409446956372115*^9, 3.409446983731456*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 StyleBox["\<\"Send to serial port\"\>", "MSG"]], "Print", "PrintUsage",
 CellChangeTimes->{3.4094469843022766`*^9},
 CellTags->"Info3409418183-4938196"],

Cell[BoxData[
 InterpretationBox[GridBox[{
    {GridBox[{
       {
        RowBox[{
         RowBox[{"SerialPortCommunicateCpp", "[", "L_List", "]"}], ":=", 
         RowBox[{"ExternalCall", "[", 
          RowBox[{
           RowBox[{"LinkObject", "[", 
            
            RowBox[{"\<\"\\\".\\\\getvoltagestm.exe\\\"\"\>", ",", "8", ",", 
             "7"}], "]"}], ",", 
           RowBox[{"CallPacket", "[", 
            RowBox[{"0", ",", 
             RowBox[{"{", "L", "}"}]}], "]"}]}], "]"}]}]}
      },
      BaselinePosition->{Baseline, {1, 1}},
      GridBoxAlignment->{
       "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, 
        "RowsIndexed" -> {}},
      GridBoxItemSize->{"Columns" -> {{
           Scaled[0.999]}}, "ColumnsIndexed" -> {}, "Rows" -> {{1.}}, 
        "RowsIndexed" -> {}}]}
   },
   BaselinePosition->{Baseline, {1, 1}},
   GridBoxAlignment->{
    "Columns" -> {{Left}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, 
     "RowsIndexed" -> {}}],
  Definition["SerialPortCommunicateCpp"],
  Editable->False]], "Print",
 CellChangeTimes->{3.409446984352349*^9},
 CellTags->"Info3409418183-4938196"]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[{
 RowBox[{
  RowBox[{"listforcall", "=", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"\"\<messageToSend\>\"", ",", "\"\<Hello World\\a more\>\""}], 
      "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"\"\<listenForReply\>\"", ",", "1"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"\"\<messagelevel\>\"", ",", "0"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"\"\<timeout\>\"", ",", "0.30"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"\"\<timeoutIsErr\>\"", ",", "0"}], "}"}], ",", " ", 
     RowBox[{"{", 
      RowBox[{"\"\<charsToRead\>\"", ",", "30"}], "}"}], ",", " ", 
     RowBox[{"{", 
      RowBox[{"\"\<terminationChar\>\"", ",", "\"\<\\a\>\""}], "}"}]}], 
    "}"}]}], ";"}], "\n", 
 RowBox[{"SerialPortCommunicateCpp", "[", "listforcall", "]"}]}], "Input",
 CellChangeTimes->{{3.4088976996988816`*^9, 3.408897729932355*^9}, {
   3.4088981993072834`*^9, 3.408898212105686*^9}, {3.408899307080182*^9, 
   3.408899363421197*^9}, 3.408899692103819*^9, {3.408899934922976*^9, 
   3.4088999422735453`*^9}, {3.408900274711568*^9, 3.4089002757430515`*^9}, {
   3.408900617885027*^9, 3.408900619427245*^9}, {3.4089019959966545`*^9, 
   3.4089020037277713`*^9}, {3.409432087740302*^9, 3.409432094610181*^9}, {
   3.4094322099159822`*^9, 3.4094322313968706`*^9}, {3.4094322902815423`*^9, 
   3.4094323529716864`*^9}, {3.4094326439200497`*^9, 3.409432644460827*^9}, {
   3.4094327961589584`*^9, 3.4094328367873793`*^9}, {3.409433139622835*^9, 
   3.409433139973339*^9}, {3.409433185839291*^9, 3.409433299903307*^9}, {
   3.409433351066877*^9, 3.4094333512371216`*^9}, {3.4094333960715904`*^9, 
   3.40943342119772*^9}, {3.4094336393714385`*^9, 3.409433689964187*^9}, {
   3.40943372923065*^9, 3.40943374716644*^9}, {3.4094340988321104`*^9, 
   3.4094341001139536`*^9}, {3.409434623716858*^9, 3.409434653249323*^9}, {
   3.4094347488167424`*^9, 3.409434776716861*^9}, {3.409434888938227*^9, 
   3.4094348891986017`*^9}, {3.409435228686762*^9, 3.4094352533722577`*^9}, {
   3.4094353128678083`*^9, 3.4094353686880736`*^9}, 3.409435406222045*^9, {
   3.4094354611510286`*^9, 3.4094355371503105`*^9}, {3.4094355678244176`*^9, 
   3.4094355938218*^9}, {3.409435734664322*^9, 3.409435734984782*^9}, {
   3.4094362858568974`*^9, 3.409436305635338*^9}, {3.4094363417272353`*^9, 
   3.4094363686659713`*^9}, {3.409436860823659*^9, 3.4094369272191315`*^9}, {
   3.4094369910909743`*^9, 3.409436996618923*^9}, {3.4094469989733725`*^9, 
   3.409447009879054*^9}}],

Cell[BoxData["\<\"Hello World\"\>"], "Output",
 CellChangeTimes->{{3.4094469909518385`*^9, 3.409447010640149*^9}}]
}, Open  ]],

Cell[BoxData[
 RowBox[{
  RowBox[{"Uninstall", "[", "link", "]"}], ";"}]], "Input"]
}, Open  ]]
},
WindowSize->{827, 385},
WindowMargins->{{0, Automatic}, {Automatic, 0}},
ShowSelection->True,
FrontEndVersion->"6.0 for Microsoft Windows (32-bit) (April 20, 2007)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{
 "Info3409418183-4938196"->{
  Cell[11058, 255, 167, 3, 40, "Print",
   CellTags->"Info3409418183-4938196"],
  Cell[11228, 260, 1161, 31, 43, "Print",
   CellTags->"Info3409418183-4938196"]}
 }
*)
(*CellTagsIndex
CellTagsIndex->{
 {"Info3409418183-4938196", 15492, 363}
 }
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[590, 23, 571, 7, 28, "Subsubtitle"],
Cell[1164, 32, 3313, 70, 432, "Input"],
Cell[4480, 104, 741, 12, 72, "Input"],
Cell[5224, 118, 659, 18, 72, "Input"],
Cell[5886, 138, 2843, 53, 192, "Input"],
Cell[8732, 193, 990, 21, 72, "Input"],
Cell[9725, 216, 239, 4, 52, "Input"],
Cell[CellGroupData[{
Cell[9989, 224, 689, 18, 72, "Input"],
Cell[10681, 244, 146, 1, 30, "Output"],
Cell[10830, 247, 203, 4, 30, "Output"],
Cell[CellGroupData[{
Cell[11058, 255, 167, 3, 40, "Print",
 CellTags->"Info3409418183-4938196"],
Cell[11228, 260, 1161, 31, 43, "Print",
 CellTags->"Info3409418183-4938196"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[12438, 297, 2498, 44, 92, "Input"],
Cell[14939, 343, 114, 1, 30, "Output"]
}, Open  ]],
Cell[15068, 347, 83, 2, 31, "Input"]
}, Open  ]]
}
]
*)

(* End of internal cache information *)
